const Base = require('./base.js');

module.exports = class extends Base {
  indexAction() {
    return this.display();
  }

  async postAction() {
    const cid = this.get('cid') || 0;
    let post = {};
    if (!think.isEmpty(cid)) {
      post = await think.model('contents').where({type: ['IN', ['post', 'post_draft']], cid: cid}).find();
      if (think.isEmpty(post)) {
        return this.redirect('/admin/manage/posts');
      }
    }
    this.assign('post', post);
    return this.display();
  }

  pageAction() {
    return this.display();
  }
};
